<?php
/**
 * 系統名稱: Lotto 系統
 * 檔案說明: 專案管理-修改
 * $Author$
 * $Id$
 *
 */
include_once("../config.inc.php");

$_LangPath = "7star7";	//語言檔參數，務必放在最前面
include_once(__Member_Path."/logincheck_nodb.php");
include_once(__Language_Path."/selectlanguage_member.php");

$fp = @file(__Membertemplate_Path."/7star7_".$_data["stype"].".html");
$fp = implode("", $fp);
$fp = setHTMLCharset($fp);
$fp = str_replace("{SelfFile}", $_SERVER["PHP_SELF"], $fp);
$fp = str_replace("{ShowAccount}", $_SESSION["Member_Info"] -> Account, $fp);
$fp = str_replace("{UserID}", $_SESSION["Member_Info"] -> ID, $fp);
$fp = str_replace("{sid}", $_data["sid"], $fp);

$intLID = (int)$_data["LottoID"];
if(empty($intLID))$intLID = 4;

$intBT = (int)$_data["Bet_Type"];
if(empty($intBT))$intBT = 7;

include_once(__Common_Path."/SysParam.inc.php");
include_once(__Common_Path."/limit/LottoLimit_".$intLID.".inc.php");
include_once(__Common_Path."/betparam/BetParam_".$intLID.".inc.php");
include_once(__Root_Path."/tmp/credit-".$_SESSION["Member_Info"] -> ID.".php");
@include_once(__Common_Path."/todaygame/Gamble".$intLID.".inc.php");
include_once(__Common_Path."/Lotto.inc.php");
include_once(__Common_Path."/ExchangeRate.inc.php");
include_once(__Modules_Path."/ChangeTime.lib.php");

$MemExchangeRate = (empty($_ECRate[$_SESSION["Member_Info"] -> ERID]["Rate"]))?1:$_ECRate[$_SESSION["Member_Info"] -> ERID]["Rate"];
//取出此期賽程
if(is_array($_arrGamble))list($intGID, $arrGamble) = each($_arrGamble);

$intTmp = $_SESSION["Member_Info"] -> CreditLine - $_arrMemStake["_SUM"];
$fp = str_replace("{CreditValue}", $intTmp, $fp);

$fp = str_replace("{LottoID}", $intLID, $fp);
$fp = str_replace("{Bet_Type}", $intBT, $fp);

if (!is_array($arrGamble)) {
	$strDate = "2100-01-01 01:01:01";
	$fp = preg_replace("/<!-- @ Number Start @ \/\/-->.+<!-- @ Number End @ \/\/-->/s", "", $fp);
} else {
	$strDate = TimeForm($arrGamble[GameDate], $arrGamble[EndGameTime], "Y-m-d H:i:s", "UToC");
}
$fp = str_replace("{EndGameTime}", $strDate, $fp);
$fp = str_replace("{GambleID}", $intGID, $fp);
$fp = str_replace("{ShowChinaTime}", DateForm(date("Y-m-d"), date("H:i:s"), "m-d H:i:s", "UToC"), $fp);
$fp = str_replace("{ShowGameNo}", $arrGamble["SerialNo"], $fp);
$fp = str_replace("{ShowGameSec}", "", $fp);

$fp = str_replace("<td class=\"rt_sp_nsbar\" id=\"NSBar".(string)$intBT."\"", "<td class=\"rt_sp_nsbar_sd\" id=\"NSBar".(string)$intBT."\"", $fp);
$fp = str_replace("{Title}", $_arrBet_Type[$_arrLotto[$intLID]["LType"]][$intBT], $fp);

$fp = str_replace("{MaxEventLimitValue}", $_SESSION["Member_Info"] -> arrEventLimit[$intLID][$intBT], $fp);
$fp = str_replace("{MaxBetLimitValue}", $_SESSION["Member_Info"] -> arrBetLimit[$intLID][$intBT], $fp);
$fp = str_replace("{LottoMaxEventLimitValue}", floor($_arrLottoLimit[$intBT][0] / $MemExchangeRate), $fp);
$fp = str_replace("{LottoMaxBetLimitValue}", floor($_arrLottoLimit[$intBT][1] / $MemExchangeRate), $fp);

$intMinStakeValue = 9999999;
$intChkMaxPayOff = 9999999;
foreach($_arrBetParam[$intBT] as $intAN => $arrBP){
	if(floor($arrBP["MinStake"] / $MemExchangeRate) < $intMinStakeValue)$intMinStakeValue = floor($arrBP["MinStake"] / $MemExchangeRate);
	if(floor($arrBP["MaxPayOff"] / $MemExchangeRate) < $intChkMaxPayOff)$intChkMaxPayOff = floor($arrBP["MaxPayOff"] / $MemExchangeRate);
}
$fp = str_replace("{MinStakeValue}", $intMinStakeValue, $fp); //最低下注金額
$fp = str_replace("{chkMaxPayOff}", $intChkMaxPayOff, $fp);	//最高派彩

$arrMoveBT = array(7 => "Unit", 8 => "Dec", 9 => "Cent", 10 => "Milli", 13 => "Milli");
$fp = preg_replace("/<!--".$arrMoveBT[$intBT]." Start\/\/-->(.+)<!--".$arrMoveBT[$intBT]." End\/\/-->/s", "", $fp);

$arrTip = array(7 => array("{Milli}", "{Cent}", "{Dec}"), 8 => array("{Milli}", "{Cent}", "{Unit}"), 9 => array("{Milli}", "{Dec}", "{Unit}"), 10 => array("{Cent}", "{Dec}", "{Unit}"), 13 => array("{Cent}", "{Dec}", "{Unit}"));
foreach($arrTip[$intBT] as $key => $strTip){
	$fp = str_replace("{Tip".$key."}", $strTip, $fp);
}

while(list($k, $v) = each($_str7Star7)){
	$fp = str_replace("{".$k."}", $v, $fp);
}

//輸出
WebOutputHTML($fp, 1);
?>